package com.rulesHello;

import com.pojo.Order;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RulesOrder {

    public static void main(String[] args) {

        Logger logger = LoggerFactory.getLogger(RulesOrder.class);
        KieServices kss = KieServices.Factory.get();
        KieContainer kc = kss.getKieClasspathContainer();
        KieSession ks = kc.newKieSession("kieSession");

        Order order = new Order();
        order.setOriginalPrice(300D);
        ks.insert(order);
        int count = ks.fireAllRules();
        System.out.println("总执行了"+count+"条规则");
        System.out.println("输出修改后的order realPrice="+ order.getRealPrice());
        ks.dispose();
    }
}
